package org.example.controller;

import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/users")
@RefreshScope
public class UserController {
    @Value("${user.name}")
    String username;
    @Value("${user.age}")
    String age;
    @GetMapping("/name")
    public String getUsername() {
        return username;
    }
    @PostConstruct
    public void init() {
        System.out.println("spring初始化调用====================");
    }
}
